﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using Scheduling.Models.Interfaces;
using Scheduling.Models.Helpers;
using Scheduling.Models.Repos.Database.Objects;

namespace Scheduling.Models.Repos.Database
{
    public class DatabaseDepartmentLoader : IDepartmentLoader
    {
        public List<Department> GetDepartments()
        {
            var db = DBContext.Create();
            var q = from d in db.Departments
                    select new { d };
            return LinqHelper.GenericMap<Department>(q, "d");
        }

        public Department GetDepartment(int ID)
        {
            var db = DBContext.Create();
            var q = from d in db.Departments
                    where(d.ID==ID)
                    select new { d };
            return LinqHelper.GenericMap<Department>(q, "d").First();
        }
    }
}